import router from '@/router/'
import Cookies from 'js-cookie'
router.beforeEach(async(to,from,next)=>{
    let uname=Cookies.get("uname");
    if(uname){//如果有令牌
        if(to.path==="/login"){//如果访问地址是/login,那么放行
            next({ path: '/' })
        }else{
            next();
        }
    }else{//如果没有token
        if(to.path==="/login"){//如果访问地址是/login,那么放行
            next();//放行
        }else{
            // next(`/login?redirect=${to.path}`);//把要请求的路径挂到路径的后面
            next("/login");
        }
    }
});

router.afterEach(() => {//后置路由

})
